/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * LaporanKeuanganHarian.java
 *
 * Created on 13 Nov 11, 21:28:38
 */
package Com.TransaksiParkirdanLaporan.Com.Laporan;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Ardha
 */
public class LaporanKeuanganHarian extends javax.swing.JDialog {

    /** Creates new form LaporanKeuanganHarian */
    public LaporanKeuanganHarian(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        headerTextLabel = new javax.swing.JLabel();
        separator = new javax.swing.JSeparator();
        tanggalLabel = new javax.swing.JLabel();
        tabelScrollPanel = new javax.swing.JScrollPane();
        laporanHarianTabel = new javax.swing.JTable();
        judulTabelLabel = new javax.swing.JLabel();
        closeButton = new javax.swing.JButton();
        buatLaporanHarianButton = new javax.swing.JButton();
        pilihTanggalChooser = new com.toedter.calendar.JDateChooser();
        kalkulasiPanel = new javax.swing.JPanel();
        totalPendapatanHarianLabel = new javax.swing.JLabel();
        pendapatanLabel = new javax.swing.JLabel();
        totalKendaraanParkirLabel = new javax.swing.JLabel();
        kendaraanLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Laporan Keuangan Harian");

        mainPanel.setBackground(new java.awt.Color(255, 255, 255));

        headerTextLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        headerTextLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        headerTextLabel.setText("Laporan Keuangan Harian");

        tanggalLabel.setText("Tanggal Transaksi");

        laporanHarianTabel.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Operator", "Nomor Polisi", "Jumlah Helm", "Biaya Parkir"
            }
        ));
        tabelScrollPanel.setViewportView(laporanHarianTabel);

        judulTabelLabel.setForeground(new java.awt.Color(255, 0, 51));
        judulTabelLabel.setText("Data Rekap Parkir Harian");

        closeButton.setText("CLOSE");
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });

        buatLaporanHarianButton.setText("Buat Laporan Keuangan Harian");
        buatLaporanHarianButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buatLaporanHarianButtonActionPerformed(evt);
            }
        });

        kalkulasiPanel.setBackground(new java.awt.Color(255, 255, 255));
        kalkulasiPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Kalkulasi Pendapatan Harian", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        totalPendapatanHarianLabel.setText("Rp. 0,00");

        pendapatanLabel.setText("Total Pedapatan Per Hari");

        totalKendaraanParkirLabel.setText("0");

        kendaraanLabel.setText("Total Kendaraan Parkir");

        javax.swing.GroupLayout kalkulasiPanelLayout = new javax.swing.GroupLayout(kalkulasiPanel);
        kalkulasiPanel.setLayout(kalkulasiPanelLayout);
        kalkulasiPanelLayout.setHorizontalGroup(
            kalkulasiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, kalkulasiPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(kalkulasiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, kalkulasiPanelLayout.createSequentialGroup()
                        .addComponent(kendaraanLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(totalKendaraanParkirLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, kalkulasiPanelLayout.createSequentialGroup()
                        .addComponent(pendapatanLabel)
                        .addGap(27, 27, 27)
                        .addComponent(totalPendapatanHarianLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        kalkulasiPanelLayout.setVerticalGroup(
            kalkulasiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(kalkulasiPanelLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(kalkulasiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(totalKendaraanParkirLabel)
                    .addComponent(kendaraanLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(kalkulasiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(pendapatanLabel)
                    .addComponent(totalPendapatanHarianLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(separator, javax.swing.GroupLayout.DEFAULT_SIZE, 770, Short.MAX_VALUE)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(judulTabelLabel)
                .addContainerGap(640, Short.MAX_VALUE))
            .addComponent(headerTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 770, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addContainerGap(513, Short.MAX_VALUE)
                .addComponent(tanggalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pilihTanggalChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addContainerGap(579, Short.MAX_VALUE)
                .addComponent(buatLaporanHarianButton)
                .addContainerGap())
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabelScrollPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 750, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(closeButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 318, Short.MAX_VALUE)
                .addComponent(kalkulasiPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(headerTextLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(separator, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(tanggalLabel)
                    .addComponent(pilihTanggalChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(judulTabelLabel)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(buatLaporanHarianButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tabelScrollPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(kalkulasiPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(closeButton)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
        LaporanController.openLaporanFrame(this);

}//GEN-LAST:event_closeButtonActionPerformed

    private void buatLaporanHarianButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buatLaporanHarianButtonActionPerformed
        if (pilihTanggalChooser.getDate() != null) {
            try {
                LaporanController.laporanHarian(pilihTanggalChooser, laporanHarianTabel);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(rootPane, ex.getMessage());
            }
            LaporanController.totalPendapatanHarian(laporanHarianTabel, totalPendapatanHarianLabel);
            LaporanController.totalKendaraanHarian(laporanHarianTabel, totalKendaraanParkirLabel);
        } else {
            JOptionPane.showMessageDialog(rootPane, "Tanggal transaksi belum dipilih");
        }
    }//GEN-LAST:event_buatLaporanHarianButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                LaporanKeuanganHarian dialog = new LaporanKeuanganHarian(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buatLaporanHarianButton;
    private javax.swing.JButton closeButton;
    private javax.swing.JLabel headerTextLabel;
    private javax.swing.JLabel judulTabelLabel;
    private javax.swing.JPanel kalkulasiPanel;
    private javax.swing.JLabel kendaraanLabel;
    private javax.swing.JTable laporanHarianTabel;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JLabel pendapatanLabel;
    private com.toedter.calendar.JDateChooser pilihTanggalChooser;
    private javax.swing.JSeparator separator;
    private javax.swing.JScrollPane tabelScrollPanel;
    private javax.swing.JLabel tanggalLabel;
    private javax.swing.JLabel totalKendaraanParkirLabel;
    private javax.swing.JLabel totalPendapatanHarianLabel;
    // End of variables declaration//GEN-END:variables
}
